package com.example.demo3;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "helloServlet", value = "/hello-servlet")
public class HelloServlet extends HttpServlet {


    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        response.setContentType("text/html");
        response.setContentType("text/html;charset=gb2312");

        PrintWriter out = response.getWriter();
        out.println("<html><body>");
        out.println("<h1 style=\"color: red\" align=\"center\">" + "冬夜读书示子聿" + "</h1>");
        out.println("<h1 style=\"color: red\" align=\"center\">" + "古人学问无遗力，少壮工夫老始成。" + "</h1>");
        out.println("<h1 style=\"color: red\" align=\"center\">" + "纸上得来终觉浅，绝知此事要躬行。" + "</h1>");
        out.println("</body></html>");
    }

    public void destroy() {
    }
}
